package api

import (
	"encoding/json"
	"net/http"

	"rt.com/mocktool/mock"
)

// SetupInfo 配置页结构
type SetupInfo struct {
	AdminPort      int // 后台端口号
	ProxyPort      int // 代理端口号
	GlobalInactive int // 全局关闭拦截
}

// loadSetupInfo 读取服务配置信息
func loadSetupInfo(w http.ResponseWriter, r *http.Request) {
	debugAPI(w, r)
	setupInfo := SetupInfo{
		AdminPort:      mock.Instance.GetConfig().AdminPort,
		ProxyPort:      mock.Instance.GetConfig().ProxyPort,
		GlobalInactive: mock.Instance.GetConfig().GlobalInactive,
	}
	result, _ := json.Marshal(setupInfo)
	w.Write(result)
}
